using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Reward", "rewardId", "Torch.WL.ConnectionString")]
	public class Tb_Reward : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_REWARDID = "rewardId";
		public const string SQLCOL_REWARDNAME = "rewardName";
		public const string SQLCOL_CREATETIME = "createTime";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Reward () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Reward (int rewardId)
		{
			this.rewardId = rewardId;
		}
		#endregion

		public override void Init (DataRow row)
		{
			rewardId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_REWARDID]);
			rewardName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_REWARDNAME]);
			createTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_CREATETIME]);
		}

		#region Properties 
		#region Property <int> rewardId
		[Property("rewardId", 4, SqlDbType.Int, true, true)]
		public int rewardId 
		{
			get { return _rewardId; }
			set { _rewardId = value; }
		}
		private int _rewardId = int.MinValue;
		#endregion

		#region Property <string> rewardName
		[Property("rewardName", 140, SqlDbType.VarChar, false, false)]
		public string rewardName 
		{
			get { return _rewardName; }
			set { _rewardName = value; }
		}
		private string _rewardName = null;
		#endregion

		#region Property <DateTime> createTime
		[Property("createTime", 16, SqlDbType.DateTime, false, false)]
		public DateTime createTime 
		{
			get { return _createTime; }
			set { _createTime = value; }
		}
		private DateTime _createTime = DateTime.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int rewardId)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(rewardId));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
